<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>添加订单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>

<div class="layui-form layuimini-form" lay-filter="orderEditFormFilter">

    <div class="layui-form-item">
        <label class="layui-form-label required">订单编号</label>
        <div class="layui-input-block">
            <input type="text" name="orderId" lay-verify="required" lay-reqtext="用户编号不能为空" placeholder="请输入用户编号"
                   value=""
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">买家电话</label>
        <div class="layui-input-block">
            <input type="text" name="buyerPhone" lay-verify="required|phone" lay-reqtext="用户姓名不能为空" placeholder="请输入用户姓名"
                   value=""
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">下单时间</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" name="orderTime" id="orderTime">

        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">状态</label>
        <div class="layui-input-block">

            <select name="state" class="state" lay-verify="" lay-filter="stateFilter">

            </select>

        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">用户ID</label>
        <div class="layui-input-block">
            <input type="text" name="userId"  lay-reqtext="用户ID不能为空" placeholder="请输入用户ID"
                   value=""
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">地址</label>
        <div class="layui-input-block">
            <input type="text" name="address"  lay-reqtext="地址不能为空" placeholder="请输入地址"
                   value=""
                   class="layui-input">
        </div>
    </div>


    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
</div>

<script src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="../../lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
<script>

    var state;

    function child(state){
        this.state = state;

        console.log("statess:"+state);

        var opt1 =new Option("已下单订单","1",false);
        var opt2 =new Option("待发货订单","2",false);
        var opt3 =new Option("已取消订单","3",false);
        var opt4 =new Option("已发货订单","4",false);
        var opt5 =new Option("已结算订单","5",false);
        var opt6 =new Option("已拒收订单","6",false);
        var opt7 =new Option("已签收订单","7",false);
        var opt8 =new Option("已退货订单","8",false);
        var opt9 =new Option("待跟进订单","9",false);

        if (state == "1") {
            $(".state").append(opt1);
            console.log("你好！");
        }else if (state == "2") {
            $(".state").append(opt2);
        }else if (state == "3") {
            $(".state").append(opt3);
        }else if (state == "4") {
            $(".state").append(opt4);
        }else if (state == "5") {
            $(".state").append(opt5);
        }else if (state == "6") {
            $(".state").append(opt6);
        }else if (state == "7") {
            $(".state").append(opt7);
        }else if (state == "8") {
            $(".state").append(opt8);
        }else if (state == "9") {
            $(".state").append(opt9);
        }else{
            $(".state").append(opt1);
            $(".state").append(opt2);
            $(".state").append(opt3);
            $(".state").append(opt4);
            $(".state").append(opt5);
            $(".state").append(opt6);
            $(".state").append(opt7);
            $(".state").append(opt8);
            $(".state").append(opt9);
        }


            layui.use(['form','element','laydate'], function () {
            var form = layui.form;
            var layer = layui.layer;
            var element = layui.element;
            var laydate = layui.laydate;
            var $ = layui.$;

            laydate.render({
                elem:'#orderTime'
                ,format: 'yyyy-MM-dd HH:mm:ss',
                value: new Date(),
            })

                // //监听状态下拉选择框
                // form.on('select(stateFilter)', function(data){
                //     console.log("状态菜单选择了~~~~~"+data.value);
                //     //得到此时菜单
                //     existState = data.value;
                // });

            //监听一级菜单添加
            form.on('submit(saveBtn)', function (data) {

                $.post("/wfx_manager/order/addOrder",
                    form.val("orderEditFormFilter")
                    ,function (res) {
                        console.log(res);
                        if (res.flag){
                            layer.msg(res.msg,function () {
                                //获取iframe的唯一标识
                                var iframeIndex = parent.layer.getFrameIndex(window.name);
                                //关闭iframe窗口
                                parent.layer.close(iframeIndex);
                            })
                        }

                        layer.msg(res.msg);

                    })


                return false;
            });



        });

    }

</script>
</body>
</html>